package vow.gui.renderer;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextArea;
import javax.swing.ListCellRenderer;

import ontology.models.contract.Obligation;
import ontology.models.contract.Obligation.Status;

public class ObligationsRenderer extends JTextArea implements ListCellRenderer{

	public ObligationsRenderer(){
        setOpaque(true);
	}
	
	@Override
	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		Obligation o = (Obligation) value;
		if(o.getStatus() == Status.PENDING){
			setBackground(Color.yellow);
		}
		if(o.getStatus() == Status.FULFILLED){
			setBackground(Color.green);
		}
		if(o.getStatus() == Status.LIVELINE_VIOLATED){
			setBackground(Color.orange);
		}
		if(o.getStatus() == Status.VIOLATED){
			setBackground(Color.red);
		}
		
		if(isSelected)
			setBackground(Color.lightGray);
		setText(o.toString());
		return this;
	}
	
}